layui.use('jquery',function(){
	var $ = layui.jquery;
	
	//加载购物车商品种数
	$.post(
		"shopcart/getCount.do?uid=1",
		function(res){
			$(".sp-cart span").html(res);
		},"json"
	);
	//加载今日必抢
	$.post(
		"product/findToday.do",
		function(res){
			var html = '<div class="item-box">';
			$(res).each(function(index){
				var pname = this.pname.length>8?this.pname.substr(0,12)+"...":this.pname;
				var delPrice = (this.unitPrice*1.6).toFixed(2);//保留2位小数
				html+='<div class="item"><a href="details.html?id='+this.id+'"><img src="/file/'+this.url+'"></a><div class="title">'+pname+'</div><div class="price"><span>￥'+this.unitPrice+'</span><del>￥'+delPrice+'</del></div></div>';
				if(index%4==3){
					html+='</div>';
					html+='<div class="item-box">';
				}
			});
			html+='</div>';
			$("#today").append($(html));
		},"json"
	);
});


